終於到了下半場的時間了呢! 15/30 挑戰已經過了一半,接下來就要進入 ERC20 Token 的解說與相關的應用。為了預熱,就讓我先來介紹後續的應用裡面常見的一些寫法跟函式庫吧!
今天要先來介紹可以讓整個開發更彈性且更具備描述力的抽象合約吧!
本日合約:
pragma solidity ^0.4.25;
contract Ownable {
address private owner;
constructor() internal {
owner = msg.sender;
}
modifier onlyOwner() {
require(isOwner());
_;
}
function isOwner() public view returns (bool) {
return owner == msg.sender;
}
}
contract Main is Ownable {
string public name = "";
function modifyName(string _name) public onlyOwner {
name = _name;
}
}
本日影片:
https://youtu.be/jdWM91sDd6s
Smart Contract 實戰教學播放清單:
https://www.youtube.com/playlist?list=PLHmOMPRfmOxSJcrlwyandWYiuP9ZAMYoF